	const http = require("http");
	const fs = require("fs");
	const { type } = require("./getType.js");
	const path = require("path");
	const u = require("url");
	const app = http.createServer(function (request, response) {
		let reqType = request.method;
		let reqUrl = u.parse(request.url).pathname;
		if (reqUrl == "/favicon.ico") { 
			return
		}
		if (reqType == "GET" && (reqUrl == "/" || reqUrl == "/index" || reqUrl == "/index.html")) {
			let data = fs.readFileSync(__dirname + "/index.html").toString();
			response.writeHead(200, {"Content-Type": "text/html"});
			response.write(data); 
			response.end();
		}else if (reqType == "GET" && reqUrl.includes(".")) {
			let data = fs.readFileSync(__dirname + reqUrl);
			response.writeHead(200, {"Content-Type": type(path.extname(reqUrl))});
			response.write(data); 
			response.end();
		}else {
			response.writeHead(404, {"Content-Type": "text/plain; charset=utf-8"});
			response.write("404 Not Found！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！"); 
			response.end();
		}
	});
	app.listen(80);